home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
EDUCATE
/
QMTEK601.ARJ
/
HEX.TEC
< prev
next >
Wrap
Text File
|
1991-03-14
|
8KB
|
153 lines
ID:HX Hexadecimal Numbers and QEMM
Quarterdeck Technical Note #190
by Vernon Balbert
Q: Why are these numbers mixed up with these letters and what
do they mean?
A: These numbers and letters are part of a numbering system
that is used by computers.
Computers don't count the way people do. People use
decimal, or base 10 for counting and we use the numbers 0-9
giving us 10 different symbols for counting. Computers, on the
other hand, use binary, a number system that uses just zeros and
ones. So, a typical binary number might look like this:
1001011011010010
Kind of confusing, huh? Well, even to programmers, these
numbers are confusing. People just don't work well with binary.
Computers do. Binary numbers can be translated to decimal quite
easily, but they just aren't neat. For instance, if you use an
eight digit binary number, you can count up to 255. Well, this
has three decimal numbers and multiples of 256 (counting 0) is
just not very neat or easy. However, there is a different way of
counting that is widely used by computer people. This is called
HEXADECIMAL. Hexadecimal is base 16. What this means is that if
you were to start counting from 0, you would continue up to some
single digit that would represent 15. And that's where the
letters come from. Hexadecimal numbers go like this:
0 1 2 3 4 5 6 7 8 9 A B C D E F
Well, part of that looks normal, at least until the 9. The
A translates as 10, the B as 11 on up until the F is equal to 15.
After F, you tack on a 1 at the beginning of the number just like
we do so you would get 10. And, yes, 10 plus 10 equal 20. Since
10 in hexa- decimal is equal to 16 in decimal, it would be
logical to assume that if 16+16=32 then 20 hexadecimal equals 32
decimal. Rest assured, it does. Often, to tell the difference
between hexadecimal and decimal numbers, programmers will use H
at the end of the number to say that it is hexadecimal, i.e.
10H. Now, if you have 8 binary numbers, you can count either to
256, or to FFH. (Remember, the H stands for hexadecimal.) This
means that you can count in multiples of 4 binary digits with one
hexadecimal digit. For instance:
10010110=96H=150 base 10
Now, you might ask, why use multiples of 4 binary digits?
Well, the answer is really quite simple. Computer people like to
group binary numbers in groups of eight. A hexadecimal number
can represent 4 binary digits. Each number is called a bit and
each group of eight bits is a byte. And computer memory is
measured in bytes. Each byte can represent one character such as
the letter "Q" or the number "3". Your hard disk is measured in
megabytes, or millions of bytes. So, hexadecimal is a number
system that both computers and humans can work with easily.
Actually, computers don't work with hexadecimal, but most
programs that work with hexadecimal numbers have routines that
translate the hexadecimal numbers to binary for the computer
because it's so easy; simply convert each hex digit into the
appropriate 4 binary digits. By the way, hexadecimal is often
referred to as "hex" for short.
Okay, now we have to delve a little into the history of IBM
PCs to understand the way you address memory.
When IBM first came out with the PC, the Intel 8088
processor was used. The 8088 can access 1 megabyte of memory.
However, the chip only has 16 bit registers. (A register is an
internal memory loca- tion.) You can only count to 65535 with 16
bits. In order to access the 20 bits outside the microprocessor,
an alternate method of ad- dressing memory was developed. So,
addresses had the following format:
ssss:oooo
The first four hex digits (ssss) are the segment address.
The last four (oooo) are the offset address. Together, these can
address the entire 1 megabyte space of the 8088. This is called
relative addressing. You never actually say the exact address
that you are pointing at, just an address relative to a different
position. For instance, if you have an address such as
1234:2319, you would take 1234H, add a 0 to the end so it turns
into 12340H and then add 2319H to it to get 14659H.
When the 80286 came out, it had 24 address lines to address
more than the 1 megabyte of memory available. (24 address lines
lets you address 16 megabytes of memory.) Additionally, the
internal registers were enlarged to 24 bits so you didn't have to
go through the segment and offset gyrations. So, you could now
use absolute addressing. The address now takes this format:
XXXXXX
Notice now, that there are 6 digits instead of two sets of 4
when an 80286 is in "protected" mode (6 digit mode). DOS,
unfortunately, only understands segmented memory addressing which
is in "real" mode. Intel built in a "real" mode into the 80286
and higher processors so that they would still understand
relative addressing. This difference is VERY important. It is
the main reason that you can't use exTENDed memory (only
available in "protected" mode) to run DOS programs (which require
"real" mode).
QEMM, QRAM and DESQview all observe the relative addressing
scheme. So, when you include or exclude areas of memory with
QEMM, you use the segment address. Typically, the only
exclusions you will use involve the area above the 640K program
space. This is a 384K area of memory that is normally used by
adapter cards and ROMs in your computer. The address range of
the lower 640K is 0000-9FFF. Remem-ber, these are the segment
addresses, not the offset addresses. The area above 640K is the
A000-FFFF range.
Here is a translation table so you can convert some common
hexadecimal addresses into decimal and back.
Common way of Decimal Hexadecimal Segment:Offset
saying it
1K 1024 400 0040:0000 or 0000:0400
2K 2048 800 0080:0000 or 0000:0800
4K 4096 1000 0100:0000 or 0000:1000
8K 8192 2000 0200:0000 or 0000:2000
16K 16384 4000 0400:0000 or 0000:4000
32K 32768 8000 0800:0000 or 0000:8000
64K 65536 10000 1000:0000
128K 131072 20000 2000:0000
256K 262144 40000 4000:0000
384K 393612 60000 6000:0000
512K 524288 80000 8000:0000
640K 655350 A0000 A000:0000
704K 720896 B0000 B000:0000
736K 753664 B8000 B800:0000
768K 786432 C0000 C000:0000
832K 851968 D0000 D000:0000
896K 917504 E0000 E000:0000
960K 983040 F0000 F000:0000
1024K 1048576 100000 1MB and beyond cannot
be addressed with the
segment:offset method.
In summary, we see that hexadecimal (or hex, for short) is
actually base 16, decimal is base 10 and binary is base 2. Hex
numbers go from 0 to F, decimal numbers go from 0 to 9 and binary
go from 0 to 1. Hex numbers are used to make it easier for
people to work with numbers that the computer uses.
Copyright (C) 1991 by Quarterdeck Office Systems
* * * E N D O F F I L E * * *